package menus_api

import (
	"gin_study_blog/common"
	"gin_study_blog/common/http"
	"gin_study_blog/models"

	"github.com/gin-gonic/gin"
)

type MenusNameResponse struct {
	ID    uint   `json:"id"`
	Path  string `json:"path"`  // 图片路径
	Title string `json:"title"` // 名称
}

// MenusNameListView 菜单名称和路径
func (MenusApi) MenusNameListView(c *gin.Context) {
	var menuNameList []MenusNameResponse
	// 如果只是查询就不需要使用指针
	common.DB.Model(models.MenuModel{}).Select("id", "title", "path").Scan(&menuNameList)
	http.IsOkWithData(menuNameList, c)
}
